// wenshidu/chufang_lsit/chufang_lsit.js
let app = getApp()
let yuming = app.globalData.yuming
const request = require('../../config/request');
var shuzong = []
var shu = []
Page({
  ...request,
  /**
   * 页面的初始数据
   */
  data: {
    yuming: yuming,
    title: '上传处方',
    heights: '',
    list_gao: '',
    xq: '',
    page: 1,
    gongwu: false,
    id: '',
    souagao: '',
    keywords: ''
  },
  keywords(e) {
    this.setData({
      keywords: e.detail.value
    })
    this.chuf_lsit()
  },
  // 放大
  fangda(e) {
    var img = e.currentTarget.dataset.img
    var list = e.currentTarget.dataset.list
    var arr = []
    for (let i in list) {
      arr.push(list[i]); //属性
    }
    wx.previewImage({
      current: img,
      urls: arr
    })
  },
  chuf_lsit() {
    this.myRequest(yuming + 'Jinghexincheng/jhxc_chufangyao_details', {
      shopId: wx.getStorageSync('shopId'),
      id: this.data.id,
      keywords: this.data.keywords
    }, "POST").then(res => {
      if (res.data.code == 200) {
        wx.hideLoading();
        shu = res.data.data
        console.log(shu)
        if (this.data.page != 1) {
          if (shu.length != 10) {
            this.setData({
              gongwu: true
            })
          }
        }
        this.setData({
          xq: shu, //地址列表
        })
      }

    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      heights: wx.getMenuButtonBoundingClientRect().top + 5,
      list_gao: wx.getMenuButtonBoundingClientRect().top + 110,
      souagao: wx.getMenuButtonBoundingClientRect().top + 100,
      id: options.id
    })

  },
  // 返回
  backs() {
    wx.navigateBack({
      delta: 0
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.chuf_lsit()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})